home *** CD-ROM | disk | FTP | other *** search
/ PC-Blue - MS DOS Public Domain Library / PC-Blue MS-DOS Public Domain Library - NYACC.iso / vol062 / grid2con.doc < prev    next >
Encoding:
Text File  |  1987-01-13  |  15.4 KB  |  387 lines

  1. .0
  2. .J 2
  3. .E
  4. .G
  5. .P 65
  6. .C 88
  7. .B 12
  8. .T 8
  9. GRID2CON
  10. (c) copyright 1983
  11.  
  12. Mark A. Herkommer
  13. PETROSPEC
  14. 4005 Burning Tree Lane
  15. Garland, Texas  75042
  16.  
  17.  
  18.  
  19. I.    ABSTRACT
  20.  
  21.     A. Program Title:    GRID2CON
  22.  
  23.     B. Programmer:        Mark A. Herkommer
  24.  
  25.     C. Date:        April 18, 1983  Rev. 2.0
  26.  
  27.     D. Language:        Advanced Basic 1.10
  28.  
  29.     E. Machine:        IBM PC, Epson MX printer, and
  30.                 one disk drive
  31.  
  32.     F. Field Length:    Approx. 55K bytes
  33.  
  34.     G. Description:        Gridding routine for randomly 
  35.                 distributed data and line printer 
  36.                 contour map generator.
  37.  
  38.     H. Input:        XYZ or LatLonZ data entered from the
  39.                 keyboard or a sequential disk file
  40.  
  41.     I. Output:        Files: Gridsave data file
  42.                 Printout: Contour map
  43. .J 1
  44. .D
  45. II.    INTRODUCTION
  46.  
  47. GRID2CON is a gridding and contouring program designed to run
  48. on the IBM PC and an EPSON MX printer.  The program's operation 
  49. can be divided into two distinct parts that can be run indepen-
  50. dently or successionally.  The first part reads X, Y, Z or Lat Lon,
  51. Z data and generates a "gridsave" file that is read by the second.
  52. The second half reads the gridsave file and generates a line printer
  53. contour map.  Two map projections are currently available for
  54. converting latitude and longitude into ground meters; Universal
  55. Transverse Mercator and Polyconic.
  56.  
  57. GRID2CON has two gridding algorithms available to the user;
  58. inverse-distance weighted and inverse-distance-squared weighted
  59. moving averaging.  A "skip fator" speed enhancer can be used to
  60. reduce the time required to grid a set of data.  As a third
  61. "gridding" option, the user can input the coefficents of a polynomial
  62. surface and have that surface contoured.
  63.  
  64. Randomly distributed (X, Y, Z or Lat, Lon, Z) data are input into the
  65. program from a disk file.  The output contour map can be viewed on
  66. the screen, printed on a line printer, or saved in a disk file.
  67. If the map is printed, the width and height of the characters can be
  68. varied to improve the resolution.  Also, maps that are wider than the
  69. paper width are automatically printed in strips so that they can be
  70. pieced together.
  71.  
  72. III.    METHOD OF SOLUTION
  73.  
  74.     A. Gridding
  75.  
  76.     Gridding is the operation that generates a Z-value at regular
  77.     and predictable intervals (X,Y locations) given randomly
  78.     distributed XYZ data points.  In version 1.0 of GRID2CON, only
  79.     rectangular gridding is performed.
  80.  
  81.     One may think of the grid as a series of of reqularly spaced
  82.     horizontal and vertical lines at the intersection of which is
  83.     a Z-value calculated.  These intersections are called grid
  84.     nodes and 4 of these define the smallest grid unit called a
  85.     grid cell.
  86.  
  87.     When gridding, the distance from the grid node to each of the 
  88.     XYZ data points (hereafter called control points), is calcu-
  89.     lated using the user's engineering units.  If the calculated
  90.     distance between the control point and grid node is less than
  91.     the "Search Radius", then the inverse-distance is used to weight
  92.     that control point's contribution to the average at that
  93.     grid node.  All the control points are tested against the search
  94.     for each of the grid nodes.  This type of weighting is used
  95.     because points further away are thought to influence the value
  96.     at the node less.  The greater the distance, the less the
  97.     weight.  The distance is calculated by:
  98.  
  99.         D^2 = ( X2 - X1 )^2 + ( Y2 - Y1)^2
  100.  
  101.     Where D is the distance between the node and the control point,
  102.     X1 is the CP X-location, X2 is the grid node X-location, Y1 is
  103.     the CP Y-location, and Y2 is the grid node Y-location.  The 
  104.     Z-value is computed by:
  105.  
  106.         Zsum = Z1/D1 + Z2/D2 + Z3/D3 + ... + Zn/Dn
  107.  
  108.     The sum of the weights is:
  109.  
  110.         Dsum = 1/D1 + 1/D2 + 1/D3 + ... + 1/Dn
  111.  
  112.     and the Z-value at the node is:
  113.  
  114.         Zvalue = Zsum/Dsum
  115.  
  116.     These calculations are performed at each node in the map area.
  117.     The search radius is  calculated as 1/2 the diagonal distance
  118.     of the map area, although this can be overridden. Nodes that
  119.     have no control points close enough to pass the search radius
  120.     test are assigned a value of 1E+32 (undefined).
  121.  
  122.     Traditionally when making line printer contour maps, each 
  123.     character of the printer is considered a node and a value is
  124.     calculated for each.  Thus, a map that figures to be 20"x20"
  125.     has 200 columns (at 10 cpi) and 160 rows (at 8 lpi) and
  126.     would require 32,000 node calculations.  For most, the time
  127.     required to calculate a grid of this size would be
  128.     prohibative.  It is because of this time consideration that
  129.     a skip factor is used.
  130.  
  131.     B. Trend Surface Coefficents
  132.  
  133.     The highest order polynomial that can be contoured is an
  134.     8th.  In this case, 45 coefficents would be required.
  135.     The number of ceofficents can be determined by:
  136.  
  137.         NCoefficents = (Order+1) * (Order+2)/2
  138.  
  139.     All required coefficents must be entered, although any can have
  140.     the default value of 0.  The coefficents  correspond to the
  141.     the polynomial thusly:
  142.  
  143.         Z-value = C1 + C2*X + C3*Y + C4*X^2 + C5*X*Y + C6*Y^2 +
  144.               C7*X^3 + C8*X^2*Y + C9*X*Y^2 + C10*Y^3 + ...
  145.  
  146.     Coefficents must be entered in this order for the calculations
  147.      to be performed correctly.
  148.  
  149.     C. Skip Factor
  150.  
  151.     The skip factor is nothing more than the number of columns
  152.     that are skipped between grid nodes on each line (row) of the
  153.     contour map.  The gridding time is reduced by a factor of the
  154.     skip factor.  In the above example, a skip factor of 30 would
  155.     mean that a total of 1280 nodes would be calculated.  Depending
  156.     upon the curvature of the surface being calculated, skip
  157.     factors as large as 1/4 the map width can produce satisfactory
  158.     results.  Between the calculated nodes the Z-values are
  159.     linearly interpolated.
  160.  
  161.     The skip factor is not used in the calculations of the 
  162.     vertical component of the line printer map.  Because of this,
  163.     map resolution remains very high in the Y-direction.
  164.  
  165. IV.    PROGRAM OPTIONS AND RESTRICTIONS
  166.  
  167.     A. Options -- gridding
  168.  
  169.     Three surface generating algortihms are available, as discussed
  170.     above.  A sutiable program for deriving the coefficents of a
  171.     trend surface is CURVFIT-3D, available from PETROSPEC.
  172.  
  173.     The scale of the map per inch will determine the number of
  174.     columns and rows in the map area.  The default character spacing
  175.     is 10 characters per inch horizontally and 8 lines per inch ver-
  176.     tically.  Thus a map 6 inches wide <the default>, will have
  177.     60 columns and 48 rows.  GRID2CON will automatically panelize 
  178.     if it cannot plot the map within the width of the panel 
  179.     set by the user <80 is the default>.  It is worth noting that
  180.     17 columns are used to draw the margins and axis labels on 
  181.     each panel.  Compressed and subscript characters are available
  182.     to persons with EPSON MX printers.  These options improve the
  183.     resolution of the map.  Vertical spacing greater than 10 cpi
  184.     will put the printer input subscript mode.
  185.  
  186.     The Search radius is calculated as 1/2 the map diagonal, 
  187.     however, this can be input when the user is queried.  If
  188.     a search radius is two small, many nodes will have 'undefined'
  189.     values, shown by a '*' on the map.  A large Search radius will
  190.     tend produce a map of moving averages for the whole map area--
  191.     this is sometimes desirable.
  192.  
  193.     B. Options -- contouring
  194.  
  195.     Panel width can be set so the map will fit on the media it
  196.     has been directed to.  The map will plot on the screen <SCRN:>
  197.     unless the user specifies otherwise.  Other specifications might
  198.     be LPT1: for the line printer, or B:MAP.FIL for a disk file.
  199.     This option has been provided so the user can save her results
  200.     in a file for future reference, or to make multiple copies
  201.     without rerunning the job.
  202.  
  203.     C. Restrictions
  204.  
  205.     Only 1000 data points can be gridded.  Points numbering over
  206.     1000 are ignored.
  207.  
  208.     Grid nodes are saved in the grid-save file of the user's
  209.     specification.  If she is using a 320K drive, this would
  210.     permit about 32K nodes to be saved without a disk full error
  211.     (c. 10 bytes/node).
  212.  
  213.     Latitude and longitude input must be positive, in decimal
  214.     degrees, and in the northern half of the western hemisphere.
  215.  
  216. V.    PROGRAM INPUT
  217.  
  218.     Keyboard input should always be in upper case letters.  There
  219.     are three styles of prompts used in the program, each asks
  220.     for a particular input data type.  They are
  221.  
  222.         "=" asks for numeric input
  223.         ":" asks for an alpha-numeric string
  224.         "?" asks for Y or N (Yes or No)
  225.  
  226.     The default value is shown between <>.
  227.  
  228.     XZY data must be in a sequential file arranged as X Y Z values.
  229.     Latitude/longitude Z values must be in a sequential file
  230.     arranged in that order.  No special characters can be present.
  231.     Data may be separated by spaces or commas.  There can be no
  232.     header cards, or any other superfluous information in the
  233.     control point file.  When plotting a trend surface,
  234.     at least 2 records must be present to define the limits
  235.     of the map area.
  236.  
  237. VI.    PROGRAM OUTPUT
  238.  
  239.     A. Grid-save file
  240.  
  241.     The grid-save file is a sequential file in ASCII format and
  242.     has the following structure:
  243.  
  244.     record 1: title
  245.     record 2: Xmin,Xmax,Ymin,Ymax,Zmin,Zmax,MAPSCALE,ISTATE,CM,
  246.           0,0,0,0,NROWS,NROWSKIP,NCOLS,NCOLSKIP,ALGORITHM#,
  247.           SEARCHRADIUS,NORDER,CHRHOR,CHRVERT
  248.     record 3-last: Zatthenode,NUMPOINTSusedtoestimateZ
  249.  
  250.     Z-values start in the upper left corner of the map area, and
  251.     move left-to-right then down, and left-to-right again, etc.
  252.     If no points passed the Search radius test, then Z=1E+32
  253.     and NPTS=0.  If a trend surface was gridded, then Z=
  254.     the calculated Z-value at the given X Y location. The
  255.     number of points used to estimate Z will always equal 1.
  256.     ISTATE is the map projection and CM is the central merridian.
  257.  
  258.     B. Contour maps
  259.  
  260.     Below is a sample contour map made from synthetic data.
  261.  
  262.  
  263.  PANEL 1 OF 1           synthetic data--ncskip=1--npts=11
  264.  
  265. ^xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+
  266. y       55555  44   333333  22  1  $$ AA  BBB   CCC  DD  EEEEy= 5
  267. y       55555  44  3333333  22 11 $$  AA  BBB  CCCC  DD  EEEEy
  268. y 44           4   333333   2 11  $$ AA   BB   CCCC CDDD  EEEy
  269. y4444         44   333333  22 11  $  AA  BBB   CCCC   DDD    y
  270. y444444  444444   33333   22 11  $$  AA  BB   CCCCC    DDD   y
  271. y  44444444444   3333    22  11 $$  AA   BB   CCCC      DDDDDy
  272. y    4444       333    222  11  $$  AA   BB  CCCC          DDy
  273. y33         333333   2222  11  $$  AAA  BBB  CCC             y
  274. y333333  333333     222   11  $$   AA   BBB  CCC             y
  275. y333333333        222   111  $$$  AAA    BBB  CCC    CCCCCCCCy
  276. y              22222  111   $$$  AAAA    BBB   CCCCCCCCCCCCCCy
  277. y        22222222    111   $$$   AAA     BBBB   CCCCCCCCCCCCCy
  278. y2222222222222      1     $$$   AAAA      BBBB    CCCCCCC   Cy
  279. y22222222        11111   $$$    AAAA       BBBBB             y
  280. y222222      1111111   $$$$$    AAA         BBBBB            y
  281. y         1111111      $$$$     AAA          BBBBBBB         y
  282. y        111111      $$$$$      AAA            BBBBBBBBBBBBBBy
  283. y  1111111         $$$$$$        AAA           BBBBBBBBBBBBBBy
  284. y1111111111      $$$$$$$$        AAAA               B   BBBBBy
  285. y1111111       $$$$$$$$$$$        AAAA                       y
  286. y1111       $$$$$$$$$$$$$$$         AAAA                     y
  287. y           $$$$$$$$     $$$$$$$     AAAAAAA             AAAAy
  288. y         $$$$$$         $$$$$$$$$    AAAAAAAAA AAAAAAAAAAAAAy
  289. y       $$$$$$           $$$$$$$$$     AAAAAAAAAAAAAAAAAAAAAAy
  290. y     $$$$$$$             $$$$$$$$      AAAAAAAAAAAAAAAA     y
  291. y   $$$$$$$$       A       $$$$$$$     AAAAAAAAAAAAAA        y
  292. y  $$$$$$$$     AAAAAAA     $$$$$$      AAAAAAAAAAA          y
  293. y $$$$$$$$     AAAAAAAAA                 AAAAAAA          $$$y
  294. y $$$$$$$     AAAAA  AAAAA                  AA         $$$$$$y
  295. y  $$$$$$     AAA      AAAA               AA         $$$$$$$$y
  296. y$$$$$$$$     AAA       AAAA                       $$$$$$$$$$y
  297. y$$$$$$$$     AAA        AAAA                     $$$$$$$$$$$y
  298. y$$$$$$$      AAA        AAAAA                $$$$$$$$$$$$$$$y
  299. y$$$$$$$$     AAA        AAAAAAA             $$$$$$$$$$$$$$$$y
  300. y$$$$$$$       AAA       AAAAAAA            $$$$$$$$      $$$y
  301. y$$$$$$$$$$     AAAA   AAAAAAAA             $$$$$$           y
  302. y$$$$$$$$$$$$    AAAAAAAAAAAAAA            $$$$$$      111111y
  303. y $$$$$$$$$$$$    AAAAAAAAAA              $$$$$$     11111   y
  304. y  $$$$$$$$$$$$      AAAAAA               $$$$$$    1111     y
  305. y   $$$$$$$$$$$$                        $$$$$$$     1111     y
  306. y    $$$$$$$$$$$$                   $$$$$$$$$$$     111      y
  307. y1    $$$$$$$$$$$                  $$$$$$$$$$       111      y
  308. y111   $$$$$$$$$$$                 $$$$$$$$$$      11111     y
  309. y1111    $$$$$$$$$$$              $$$$$$$$$$$      111111    y
  310. y  1111   $$$$$$$$$$$$          $$$$$$$$$$$$$      11111111  y
  311. y    111    $$$$$$$$$$$$$     $$$$$$$$$$$$$$$      11111111  y
  312. y     111    $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$       111111111y
  313. y     111     $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$        111111  y=-1
  314. -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
  315.  !                                                          !
  316. -1                                                           5
  317.  
  318. Contour interval            =  .3 
  319. Column skip factor          =  1 
  320. Gridded by inverse-distance-squared weighting
  321.  
  322.               *** KEY ***
  323.  9.000E-01 <= value <  1.200E+00       ="E"
  324.  1.200E+00 <= value <  1.500E+00       =" "
  325.  1.500E+00 <= value <  1.800E+00       ="D"
  326.  1.800E+00 <= value <  2.100E+00       =" "
  327.  2.100E+00 <= value <  2.400E+00       ="C"
  328.  2.400E+00 <= value <  2.700E+00       =" "
  329.  2.700E+00 <= value <  3.000E+00       ="B"
  330.  3.000E+00 <= value <  3.300E+00       =" "
  331.  3.300E+00 <= value <  3.600E+00       ="A"
  332.  3.600E+00 <= value <  3.900E+00       =" "
  333.  3.900E+00 <= value <  4.200E+00       ="$"
  334.  4.200E+00 <= value <  4.500E+00       =" "
  335.  4.500E+00 <= value <  4.800E+00       ="1"
  336.  4.800E+00 <= value <  5.100E+00       =" "
  337.  5.100E+00 <= value <  5.400E+00       ="2"
  338.  5.400E+00 <= value <  5.700E+00       =" "
  339.  5.700E+00 <= value <  6.000E+00       ="3"
  340.  6.000E+00 <= value <  6.300E+00       =" "
  341.  6.300E+00 <= value <  6.600E+00       ="4"
  342.  6.600E+00 <= value <  6.900E+00       =" "
  343.  6.900E+00 <= value <  7.200E+00       ="5"
  344. undefined                              ="*"
  345. .D
  346. VII.     LICENSE
  347.  
  348.     You may:
  349.  
  350.     A.    use this program on a single machine;
  351.  
  352.     B.    copy this program into any machine readable or printed
  353.         form for backup in support of your use on a single 
  354.         machine;
  355.  
  356.     C.    copy this documentation for personal use or use within
  357.         your organization;
  358.  
  359.     D.    terminate this license by destroying all machine
  360.         readable and printed copies, including all modifica-
  361.         tions and portions of this program contained or merged
  362.         into other programs;
  363.  
  364.     E.     transfer this license to another party only if the
  365.         other party accepts the terms and conditions of this
  366.         license.  If you transfer this program, then you must
  367.         at the same time either transfer all copies whether
  368.         in machine readable or printed form to the same party
  369.         or destroy all copies not transferred, including all
  370.         modifications and portions of the program contained
  371.         or merged into other programs.
  372.  
  373.     You may not:
  374.  
  375.     A.    transfer this license except as expressly provided
  376.         for in this license.
  377.  
  378.     Term:
  379.  
  380.     This license is in effect until terminated.  If you transfer
  381.     posession of any copy, modification or merged portion of this
  382.     program to another party, your license is automatically 
  383.     terminated.
  384. fafaifae+n un ohE,s hhatfaenalue <  5.100E+00       =" "
  385.  5.100E+00 <= value <  5.400E+00       ="2"
  386.  5.400E+00 <= value <  5.700E+00       =" "
  387.  5.700E+00 <= value <  6